/*
 * @version: 1.0
 * @Author: zhl
 * @Date: 2021-10-19 11:53:16
 * @LastEditors: zhl
 * @LastEditTime: 2022-01-14 14:19:46
 * @Description: 文件实现描述
 */
#ifndef __MODBUS_MAIN_H__
#define __MODBUS_MAIN_H__

#include <iostream>
#include <memory>

#include <unordered_map>
#include "CConfigManager.h"
#include "CMosquittoManager.h"
#include "IChannel.h"

#include "global_data_struct.h"

#ifdef __cplusplus
extern "C"{
#endif
/**
 * @brief Get the module name object
 * 
 * @return char* 
 */
extern char *get_module_name();
/**
 * @brief modbus模块调用接口
 * 
 * @param cm     - 配置管理指针
 * @param sp_ptr - 串口通信模块指针
 * @param mm     - mqtt管理指针
 * @param dev    - 任务参数
 * @return int 
 */
extern int run(std::shared_ptr<CConfigManager> cm, std::shared_ptr<IChannel> channel_ptr, std::shared_ptr<CMosquittoManager> mm, IModule &im, std::shared_ptr<TASK_PARAMS> dev);

extern int  write_request_frame(int slave_id, std::shared_ptr<MODBUS_COMMAND> modbus_control, std::string &value, uint8_t *frame, int frame_len);
extern int  read_request_frame(int slave_id, std::shared_ptr<MODBUS_REQUEST> modbus_request, uint8_t *frame, int frame_len);

#ifdef __cplusplus
}
#endif

#endif /* __MODBUS_MAIN_H__ */
